<template>
    <div class="my-box">
        <div class="my-top">
            <span class="setep" @click="goRoter('setup')"></span>
            <div class="user-info">
                <div class="name">{{mobileValue | phoneFilter}}</div>
                <div class="avatar"></div>
            </div>
        </div>
        <div class="wallet-info bd-t">
            <div class="rows bd-r">
                <span class="amount">{{accountInfo.reserveFund}}</span>
                <span class="name">余额</span>
            </div>
            <div class="rows bd-r">
                <span class="amount">{{accountInfo.coinAmount}}</span>
                <span class="name">ORG</span>
            </div>
            <div class="rows">
                <span class="amount">{{accountInfo.deposit}}</span>
                <span class="name">冻结金额</span>
            </div>
        </div>
        <div class="my-wallet">
            <div class="title bd-b">我的钱包</div>
            <div class="rows-flex">
                <div class="flex" @click="goRoter('wallet', true)">
                    <span class="icon icon-wallet"></span>
                    <span class="name">我的钱包</span>
                </div>
                <!-- <div class="flex" @click="goRoter('withdrawal/user/list')"> -->
                <div class="flex" @click="goRoter('payType?type=1', true)">
                    <span class="icon icon-receiving"></span>
                    <span class="name">收款设置</span>
                </div>
                <div class="flex" @click="goRoter('gift', true)">
                    <span class="icon icon-gift"></span>
                    <span class="name">邀请有礼</span>
                </div>
                <div class="flex" @click="goRoter('questionList')">
                    <span class="icon icon-service"></span>
                    <span class="name">常见问题</span>
                </div>
                <!-- <div class="flex" @click="goRoter('customer/list')">
         <span class="icon icon-service"></span>
         <span class="name">在线客服</span>
       </div> -->
            </div>
        </div>
        <tab-bar />
    </div>
</template>
<script>
import {
  mapGetters
} from 'vuex';
export default {
  name: 'my',
  data() {
    return {
      isActive: false // 用户是否激活
    };
  },
  computed: {
    ...mapGetters(['accountInfo', 'mobileValue'])
  },
  created() {
    this.getUserStatus();
    this.$store.dispatch('setAccountInfo');
  },
  mounted() {},
  methods: {
    getUserStatus() {
      this.$API.user.getUserStatus({}).then(res => {
        if (!res.code) {
          this.isActive = res.data;
        }
      });
    },
    goRoter(path, isRule) {
      if (isRule) {
        if (!this.isActive) {
          this.$API.user.getUserStatus({}).then(res => {
            if (!res.code) {
              if (res.data) {
                this.$router.push({
                  path: '/' + path
                });
              } else {
                this.$toast('账户尚未激活，请先去激活！');
              }
              this.isActive = res.data;
            }
          });
          return false;
        }
        this.$router.push({
          path: '/' + path
        });
      } else {
        this.$router.push({
          path: '/' + path
        });
      }
    }
  }
};
</script>
<style lang="less" scoped>
    .my-box {
        background-color: #fff;

        .my-top {
            height: 476px;
            background-image: url('../../assets/images/icon-my-bg.png');
            background-repeat: no-repeat;
            background-size: 100% 100%;
            display: flex;
            justify-content: center;
            align-items: center;

            .setep {
                position: absolute;
                top: 80px;
                right: 41px;
                ;
                width: 52px;
                height: 52px;
                display: block;
                background-image: url('../../assets/images/icon-setup.png');
                background-repeat: no-repeat;
                background-size: contain;
            }

            .name {
                font-size: 30px;
                height: 30px;
                color: #fff;
                text-align: center;
            }

            .avatar {
                width: 130px;
                height: 130px;
                border-radius: 130px;
                margin: 51px auto 0;
                background-color: #eee;
                background-image: url(../../assets/images/icon-kf-avatar.png);
                background-position: center center;
                background-size: contain;
                background-repeat: no-repeat;
            }
        }

        .wallet-info {
            display: flex;
            padding: 45px 0;
            margin: 60px 30px 0;

            .rows {
                flex: 1;
                text-align: center;

                .amount {
                    display: block;
                    font-size: 30px;
                    color: #FFBB00;
                }

                .name {
                    color: #666;
                    font-size: 24px;
                }
            }

            .rows:first-child {
                border-left: none;
            }
        }

        .my-wallet {
            .title {
                padding: 20px 0;
                color: #333;
                font-size: 32px;
                margin: 0 30px;
            }

            .rows-flex {
                display: flex;
                padding: 30px 0;

                .flex {
                    flex: 1;
                    padding: 0 30px;
                    font-size: 24px;
                    text-align: center;

                    .icon {
                        display: inline-block;
                        width: 46px;
                        height: 40px;
                        background-repeat: no-repeat;
                        background-position: center center;
                    }

                    .icon-wallet {
                        background-image: url('../../assets/images/icon-wallet.png');
                        background-size: 46px 40px;
                    }

                    .icon-receiving {
                        background-image: url('../../assets/images/icon-receiving.png');
                        background-size: 46px 35px;
                    }

                    .icon-gift {
                        background-image: url('../../assets/images/icon-gift.png');
                        background-size: 38px 40px;
                    }

                    .icon-service {
                        background-image: url('../../assets/images/icon-service.png');
                        background-size: 40px 42px;
                    }

                    .name {
                        text-align: center;
                        display: block;
                    }
                }
            }
        }

        .telephone {
            position: absolute;
            bottom: 185px;
            left: 0;
            right: 0;
            text-align: center;
            font-size: 24px;
            color: #999;
        }
    }
</style>
